-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(snackgame): 스낵게임 Biz를 추가한다 #177
Conversation
3ae526b
to
5cfdbb1
Compare
) | ||
@PostMapping("/{sessionId}/streaks") | ||
fun removeStreaks( | ||
@Authenticated member: Member, | ||
@PathVariable sessionId: Long, | ||
@RequestBody streaksRequest: StreaksRequest | ||
): ResponseEntity<SnackgameResponse?> { | ||
val game = snackgameBizService.removeStreaks(member.id, sessionId, streaksRequest) | ||
return game.let { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
한번의 호출로 여러 개의 스트릭을 받을 수 있도록 API 개선했습니다
fun remove(streak: Streak) { | ||
val removedSnacks = board.removeSnacksIn(streak) | ||
this.score += removedSnacks.size | ||
if (removedSnacks.any(Snack::isGolden)) { | ||
this.board = board.reset() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
황금스낵을 제거한 경우에도 보드를 교체하지 않는 문제가 있었습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
혹시 어떤부분이 문제였는지 말씀해주시면 감사하겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금은 this.board = board.reset()
으로 표현이 되어있는데요,
기존엔 board.reset()
만 있어 리셋한 보드가 저장되지 못하는 상황이었습니다.
추가로 board.reset의 반환형도 Board가 아닌, List<List> 으로 되어있어 살~짝 고쳤습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 그렇네요 더 신경쓰겠습니다..!
if (yDif == 0 && xDif == 0) { | ||
return false | ||
} | ||
return yDif * xDif == 0 || yDif == xDif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존
yDif <= 1 && xDif <= 1
개선
직선상에 있거나(기울기 0), 대각선상에 있는 경우(기울기 절대값 1)를 조금 더 명확하게 표현했습니다.
yDif * xDif == 0 || yDif == xDif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 방법이..! 🧐
src/main/java/com/snackgame/server/game/snackgame/core/domain/Streak.kt
Outdated
Show resolved
Hide resolved
fun removeStreaks(memberId: Long, sessionId: Long, streaks: StreaksRequest): SnackgameResponse? { | ||
val game = snackGameRepository.getBy(memberId, sessionId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
새 도메인 용어 '스트릭'을 적용했습니다
import com.snackgame.server.game.snackgame.exception.InvalidStreakException | ||
import kotlin.math.abs | ||
|
||
class Streak(val coordinates: List<Coordinate>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kotlin List
는 불변입니다. (가변은 MutableList
)
따라서 toCoordinates()
를 제거, 외부에 공개 (private 제거) 하여 코드를 줄였습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 제 생각이 짧았습니다..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전혀 아닙니다!!
기존 코드도 너무 잘해주셨다고 생각해요
정환님 방식으로 해석하고 표현한 부분들에서 고민이 많이 느껴졌습니다..
저는 거기다가 포장지만 살짝 씌운거구용
한번에 완성도 있는 코드를 뚝딱 만들어낼 순 없죠
급할것 없이 이렇게 단계적으로 같이 해봅시다~
* <p>[1, 1]</p> | ||
* <p>[<b>9</b>, 2]</p> | ||
* 9는 황금사과이다. | ||
* 다음과 같은 보드를 생성합니다. | ||
* 9는 황금 스낵입니다 | ||
* | ||
* `1`, `8` | ||
* | ||
* **`(9)`**, `2` | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KDoc은 처음 들어봤습니다. 앞으로 적용해둘게요
@@ -33,7 +33,7 @@ abstract class Session( | |||
val currentState: SessionStateType | |||
get() = sessionState.current | |||
|
|||
abstract fun getMetadata(): Metadata | |||
abstract val metadata: Metadata | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
변경을 하게 된 이유가 궁금합니다! 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
게임의 입장에서 Metadata는 함수(행위)보다는 속성(property)의 성질이 더 강한데요.
그래서 처음부터 property로 표현하고 싶었는데, 당시엔 문법이 익숙하지 않아 함수로 표현하게 되었었네요 ㅎㅎ;
그러다가 오늘 이걸 발견해서 마침내 적절한 형태로 변경하게 된 것이었던 것이었다...입니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
답변 감사합니다 ㅎㅎ
저도 이번기회에 덕분에 코틀린 문법 하나 배워갑니다!
src/main/java/com/snackgame/server/game/snackgame/core/domain/Streak.kt
Outdated
Show resolved
Hide resolved
…Streak.kt Co-authored-by: 0chil <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
너무 고생하셨습니다! 무한모드까지 깜짝 선물로 해두셨군요
검증부분은 한 수 또 배워갑니다 🫢
…Streak.kt Co-authored-by: 0chil <[email protected]>
눈에 보이는 부분들 다듬다보니 사이즈가 커졌습니다 🙇🏻
미리 죄송합니다
Streak
,Snackgame
,SnackgameBiz
클래스 위주로 보시면 될 것 같습니다관련 이슈
변경 사항
스낵게임 Biz 추가
기존 스낵게임 세션과 분리해서 관리할 목적
패키지 분리
game.snackgame.core
,game.snackgame.infinite
game.snackgame.biz
(게임 외 다른 도메인은 세션의 도메인 활용)사소한 오류 수정